package dungeonPackage;

import static org.junit.Assert.*;

import org.junit.*;

import squareBorderPackage.*;

/**
 * A class collecting tests for the class of shafts.
 * 
 * @author Jessa Bekker & Esther Alberts
 * @version 1.0
 */
public class ShaftTest {

	/**
	 * Class variables referencing shafts that do not change during the
	 * entire test case.
	 */
	private static Shaft<AccessibleSquare> defaultShaft;

	/**
	 * Class variables referencing orientations that do not change during the
	 * entire test case.
	 */
	private static Orientation defaultOrientation, orientation1, orientation2, orientation3, coSquare1, coSquare2; 
	
	/**
	 * Class variables referencing Squares that do not change during the
	 * entire test case.
	 */
	private static NormalSquare square1, square2;

	
	/**
	 * Set up an immutable test fixture.
	 * 
	 * @post	The variable defaultOrientation references a new Orientation with coordinates (30,0,0)
	 * @post	The variable orientation1 references a new Orientation with coordinates (0,0,30)
	 * @post	The variable orientation2 references a new Orientation with coordinates (0,30,0)
	 * @post	The variable orientation3 references a new Orientation with coordinates (10,10,0)
	 * @post	The variable coSquare1 references a new Orientation with coordinates (9,0,0)
	 * @post	The variable coSquare2 references a new Orientation with coordinates (10,0,0)
	 * @post 	The variable defaultShaft references a new Shaft with maxCoordinates defaultOrientation
	 * @post	The variables square1, square2 reference 
	 * 			a new NormalSquare with a temperature of 25 degree celsius and humidity of ten percent.
	 * @post	square1 has a open door in its westDirection and square2 has a slippery wall in its eastDirection.
	 * @post	square1 is placed at coSquare1 and square2 is placed at coSquare2 in defaultShaft
	 */
	@BeforeClass
	public static void setUpBeforeClass() {
		defaultOrientation = new Orientation(30, 0, 0);
		orientation1 = new Orientation(0, 0, 30);
		orientation2 = new Orientation(0, 30, 0);
		orientation3 = new Orientation(10, 10, 0);
		coSquare1 = new Orientation(9, 0, 0);
		coSquare2 = new Orientation(10, 0, 0);
		defaultShaft = new Shaft<AccessibleSquare>(defaultOrientation);
		square1 = new NormalSquare();
		square2 = new NormalSquare();
		new Door(true, square1, Direction.WEST);
		new Wall(true, square2, Direction.EAST);
		defaultShaft.setSquareAt(coSquare1, square1);
		defaultShaft.setSquareAt(coSquare2, square2);
	}
	
	@Test
	public void initializeObject_LegalCase() {
		assertTrue(defaultShaft.getMaxCoordinates().equals(defaultOrientation));
		assertTrue(defaultShaft.getShaftDirections()[0].equals(Direction.EAST));
		assertTrue(defaultShaft.getShaftDirections()[1].equals(Direction.WEST));
	}

	@Test
	public void isValidOrientation_IllegalCases(){
		//orientatie null
		assertFalse(defaultShaft.isValidOrientation(null));
		//orientatie waarbij de z niet nul is
		assertFalse(defaultShaft.isValidOrientation(orientation3));
	}
	
	@Test
	public void isValidOrientation_LegalCases(){
		assertTrue(defaultShaft.isValidOrientation(orientation1));
		assertTrue(defaultShaft.isValidOrientation(orientation2));
	}
	
	@Test
	public void doorInsertion(){
		Orientation westOrientation = new Orientation(8, 0, 0);
		Orientation eastOrientation = new Orientation(11, 0, 0);
		NormalSquare square = new NormalSquare();
		assertTrue(defaultShaft.doorInsertion(square, westOrientation));
		assertFalse(defaultShaft.doorInsertion(square, eastOrientation));
	}
	
	@Test
	public void canHaveAsSquareAt() {
		Orientation westOrientation = new Orientation(8, 0, 0);
		Orientation eastOrientation = new Orientation(11, 0, 0);
		NormalSquare square = new NormalSquare();
		assertFalse(defaultShaft.canHaveAsSquareAt(square, westOrientation));
		assertTrue(defaultShaft.canHaveAsSquareAt(square, eastOrientation));
	}
	
}